I am using this code to get all synonyms from the text in document named "answer_tokens.txt" it is only listing the words in the document without the synonyms. can someone check it out? from nltk.corpus import wordnet with open('answer_tokens.txt') as a: #opening the tokenised answer file wn_tokens = (a.read()) #printing the answer tokens word by word as opened print('==========================================') synonyms = [] for b in word_tokenize(wn_tokens): print (str (b))
for syn in wordnet.synsets (b): for l in syn.lemmas(b): synonyms.append(l.name())
You must be logged in to post. Please login or register an account.